package com.lemi.common.resp;

import lombok.Data;

/**
 * @author kevin
 * @since 2020/7/3 2:52 PM
 */
@Data
public class ResponseMessage {
    private boolean success;

    private String msg;

    private String code;

    private Object data;


    public static ResponseMessage success(String message) {
        return new ResponseMessage(true, message, "200");
    }

    public static ResponseMessage success(Object obj) {
        return new ResponseMessage(true, "success", "200", obj);
    }

    public static ResponseMessage success(String message, Object obj) {
        return new ResponseMessage(true, message, "200", obj);
    }

    private ResponseMessage(boolean success, String message, String code) {
        this.success = success;
        this.msg = message;
        this.code = code;
        this.data = "";
    }

    public ResponseMessage(boolean success, String message, String code, Object obj) {
        this.success = success;
        this.msg = message;
        this.code = code;
        this.data = obj;
    }

    public static ResponseMessage error(String message) {

        return new ResponseMessage(false, message, "4001");
    }

    public static ResponseMessage error(String message, String code) {

        return new ResponseMessage(false, message, code);
    }
}
